﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Library
{
    public enum Chat
    {
        Co = 1,
        Ro = 2,
        Tep = 3,
        Bich = 4
    }
    public enum LabaiDB
    {
        At = 1,
        J = 11,
        Q = 12,
        K = 13
    }
    public class BoBai
    {
        public List<LaBai> list = new List<LaBai>();
        public static List<Image> listhinh()
        {
            var lista = new List<Image>();
            for (int i = 1; i < 53; i++)
                lista.Add(Image.FromFile(string.Format(@"la bai\{0}.png", i)));
            return lista;
        }

        public BoBai()
        {
            var so = Enumerable.Range(1, 13);
            var chat = Enumerable.Range(1, 4);

            var a = from k in so
                    from q in chat
                    select new { k, q };
            int i = 0;
            a.ToList().ForEach(p =>
            {
                string b = ((Chat)p.q).ToString();
                string c = ((LabaiDB)p.k).ToString();
                list.Add(new LaBai(c, b, listhinh()[i]));
                i++;
            });
        }
        public  LaBai LayTuTen(string so, string ten)
        {
            LaBai lb = list.Single(p => p.So == so && p.Ten == ten);
            return lb;
        }
        public static List<T> Randomize<T>(List<T> list, int solabai)
        {
            List<T> randomizedList = new List<T>();
            Random rnd = new Random();
            while (solabai > 0)
            {
                int index = rnd.Next(0, list.Count);
                randomizedList.Add(list[index]);
                list.RemoveAt(index);
                solabai--;
            }
            return randomizedList;
        }
    }
}
